package com.itany.controller;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/test")
public class TestController {


      @RequestMapping("/getComBox")
      public List<Map<String,Object>> getComBox(){
          List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();

          for(int i=0;i<10;i++){
              Map<String,Object> map = new HashMap<String,Object>();
              map.put("label",i+1);
              map.put("value","用户"+i);
              list.add(map);
          }
          return list;
      }


      @RequestMapping("/getData")
      public Map<String,Object> getData(@RequestParam(name = "page",required = false,defaultValue = "1") Integer pageNo,
                                        @RequestParam(name = "rows",required = false,defaultValue = "10")Integer pageSize,
                                        String name){
        Map<String,Object> map = new HashMap<String,Object>();
        List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
        for(int i=0;i<10;i++){
            Map<String,Object> vo = new HashMap<String,Object>();
            vo.put("id",i+1);
            vo.put("name","用户"+i);
            Map<String,String> vo1 = new HashMap<String,String>();
            vo1.put("id","100");
            vo1.put("name","抽烟");
            vo.put("hobby",vo1);
            list.add(vo);
        }
        map.put("total",100);
        map.put("rows",list);
        return map;
      }

      @RequestMapping("/getTree")
      public List<Map<String,Object>> getTree(Integer id){
          List<Map<String,Object>> list1 = new ArrayList<Map<String,Object>>();
          for(int i=0;i<10;i++){
              Map<String,Object> vo1 = new HashMap<String,Object>();
              vo1.put("id",i+1);
              vo1.put("text","节点"+i);
              vo1.put("checked",false);
              vo1.put("state","closed");
       /*       if(i==2||i==5){
                  List<Map<String,Object>> list2 = new ArrayList<Map<String,Object>>();
                   for(int j=0;j<5;j++){
                       Map<String,Object> vo2 = new HashMap<String,Object>();
                       vo2.put("id",j+10);
                       vo2.put("text","子节点"+j);
                       vo2.put("checked",true);
                       list2.add(vo2);
                   }

                  vo1.put("children",list2);
              }*/
              list1.add(vo1);
          }

          return  list1;
      }


}
